//
//  NetWorking.h
//  KaKaWallet
//
//  Created by admin on 16/5/29.
//  Copyright © 2016年 ibendi. All rights reserved.
//http://blog.csdn.net/ckl520csdn/article/details/52698915 Networking https
//http://blog.csdn.net/dkq972958298/article/details/53991422  Networking https

#import <Foundation/Foundation.h>


@protocol NetworkingDelegate <NSObject>

- (void)successWithTask:(NSURLSessionDataTask *)task
         responseObject:(id)responseObject;

@optional
- (void)progressWithProgress:(NSProgress *)progress;

- (void)failureWithTask:(NSURLSessionDataTask *)task error:(NSError *)error;

@end




@interface ZYNetWorking : NSObject

@property (weak, nonatomic) id<NetworkingDelegate>delegate;
@property (assign, nonatomic) BOOL isCache;
@property (assign, nonatomic) CGFloat cacheTime;

+ (instancetype)shared;

- (void)getRequest:(NSString *)urlString parameters:(id)parameters;
- (void)postRequest:(NSString *)urlString parameters:(id)parameters;
- (void)upData:(NSString *)URLString parameters:(id)parameters fileData:(NSData *)fileData name:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType;
- (void)upImage:(NSString *)URLString parameters:(id)parameters image:(UIImage *)image   fileName:(NSString *)fileName;

/**
 *  get 请求
 */
- (void)getRequest:(NSString *)urlString parameters:(id)parameters success:(void(^)(id responseObject))success failure:(void (^)(NSError *error))failure ;
/**
 *  post 请求
 */
- (void)postRequest:(NSString *)urlString parameters:(id)parameters success:(void(^)(id responseObject))success failure:(void(^)(NSError *error))failure;
/**
 *  上传图片
 *  @param name       图片名字 fild
 *  @param fileName  图片路径 [[NSDate date] timeIntervalSince1970]
 */
- (void)upImage:(NSString *)URLString parameters:(id)parameters image:(UIImage *)image name:(NSString *)name fileName:(NSString *)fileName success:(void(^)(id responseObject))success failure:(void(^)(NSError *error))failure;
/**
 *  上传文件
 *  @param fileName   图片名字 fild
 *  @param mimeType   图片路径 [[NSDate date] timeIntervalSince1970]

 */
- (void)upData:(NSString *)URLString parameters:(id)parameters fileData:(NSData *)fileData name:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType success:(void(^)(id responseObject))success failure:(void(^)(NSError *error))failure;

@end
